<?php
include("../connection/connection.php");
include("reportFunctions.php");
$distId=$_REQUEST['distId'];
$sqlReport = "SELECT distinct `district_id`,`district_name`,`block_id`,`block_name` FROM `tbl_lookup_location` where `district_id` = ".$distId." group by `block_id`";
$queryReport = mysql_query($sqlReport);
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Block</title>
</head>
<body>
<table border="0" width="810" cellspacing="0" cellpadding="0">
	<tr>
		<td width="900" height="26" bgcolor="#E9E9E9">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
	  <font face="Verdana" color="#224568">Block wise Percentage of non repairable and abandoned handpumps (as per PHED)</font></span></td>
	</tr>
	<tr><td bgcolor="#E9E9E9" height="26"><div align="center"><font face="Verdana" style="font-size: 9pt; font-weight: 700" color="#224568">Table 25 </font></div></td>
	</tr>
	<tr>
		<td bgcolor="#E9E9E9" height="56">
		<table border="1" width="810" cellspacing="0" cellpadding="0" height="47" bgcolor="#C5D8EB">
			<tr>
				<td width="116" align="center">
				<font style="font-size: 8.5pt" face="Verdana">District</font></td>
				<td width="126" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Block</font></td>
				<td width="116" align="center">
				<p align="center"><font face="Verdana" style="font-size: 8.5pt">
			  Total Nonfunctional</font></td>
				<td width="104" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Non repairable</font></td>
				<td width="97" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Abandoned</font></td>
				<td width="124" align="center">
				<font face="Verdana" style="font-size: 8.5pt">Percent Non repairable</font></td>
				<td width="121" align="center">
				<font face="Verdana" style="font-size: 8.5pt">Percent Abandoned</font></td>
			</tr>
			<?php
			//$numVillage=0;
			//$numFormVill=0;
			while($rowReport = mysql_fetch_array($queryReport)) {
			$non_funct=getTotalNotRepairable($rowReport['block_id'],'Non Repairable')+getTotalNotRepairable($rowReport['block_id'],'Abondoned');
			?><tr bgcolor="#FFFFFF">
				
				<td width="116" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $rowReport['district_name'];?></font></td>
				<td align="center" width="126"><font face="Verdana" style="font-size: 8.5pt"><?php echo $rowReport['block_name'];?></font></td>
				<td align="center" width="116"><font face="Verdana" style="font-size: 8.5pt"><?php echo $non_funct; //getTotalNotfunctional($rowReport['block_id'],'NOT FUNCTIONAL');?></font></td>
				<td align="center" width="104"><font face="Verdana" style="font-size: 8.5pt"><?php echo $non_rep=getTotalNotRepairable($rowReport['block_id'],'Non Repairable');?></font></td>
				<td align="center" width="97"><font face="Verdana" style="font-size: 8.5pt"><?php echo $non_abn=getTotalNotRepairable($rowReport['block_id'],'Abondoned');?></font></td>
				<td width="124" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php //echo getPercentNotRepairable($rowReport['block_id'],'Non Repairable');
				if($non_funct==0){
				echo "0.00";
				}else{
				echo number_format(($non_rep/$non_funct)*100,2,'.','');}
				
				?></font></td>
				<td align="center" width="121"><font face="Verdana" style="font-size: 8.5pt"><?php //echo getPercentNotRepairable($rowReport['block_id'],'Abondoned');
				if($non_funct==0){
				echo "0.00";
				}else{
				echo number_format(($non_abn/$non_funct)*100,2,'.','');}
				
				?></font></td>
				
				
				
			</tr>
			<?php
			$tot_non_funct+=$non_funct;
			}
			?>
			<tr bgcolor="#E9E9E9">
				<td width="116" align="center"><font face="Verdana" style="font-size: 8.5pt">Total</font></td>
				<td width="126" align="center"><font face="Verdana" style="font-size: 8.5pt">&nbsp;</font></td>
				<td align="center" width="116"><font face="Verdana" style="font-size: 8.5pt"><?php echo $tot_non_funct; //getSumfunctionalStatus($distId,'NOT FUNCTIONAL');?></font></td>
				<td align="center" width="104"><font face="Verdana" style="font-size: 8.5pt"><?php echo $tot_non_rep=getSumRepairableStatus($distId,'Non Repairable');?></font></td>
				<td align="center" width="97"><font face="Verdana" style="font-size: 8.5pt"><?php echo $tot_abn=getSumRepairableStatus($distId,'Abondoned');?></font></td>
				<td width="124" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php //echo getSumPercentNotRepairable($distId,'Non Repairable');
				if($tot_non_funct==0){
				echo "0.00";
				}else{
				echo number_format(($tot_non_rep/$tot_non_funct)*100,2,'.','');}
				?></font></td>
				<td align="center" width="121"><font face="Verdana" style="font-size: 8.5pt"><?php //echo getSumPercentNotRepairable($distId,'Abondoned');
				if($tot_non_funct==0){
				echo "0.00";
				}else{
				echo number_format(($tot_abn/$tot_non_funct)*100,2,'.','');}
				?></font></td>
			</tr>
		</table>
		</td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>



</body>

</html>
